<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
  <style>
    .container {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }

    @keyframes shake {
      0% {
        opacity: 0;
        font-size: 14px;
      }

      50% {
        opacity: 0.3;
        font-size: 60px;
      }

      100% {
        opacity: 1;
        font-size: 40px;
      }
    }

    .v-enter-active,
    .v-leave-active {
      animation: shake 3s linear;
    }

    .v-move {
      transition: all .5s ease-in;
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
    /* 
       1.状态动画
       - 假设变量初始值为1
       - 修改后变量变为10
       - 变化过程中从1变为2，2变为3，3变为4逐步变到10
    */
    const app = Vue.createApp({
      template: `
      <div class="container">
        <transition-group>
          <span >{{count}}</span>
        </transition-group>
        <button @click="handleClick">添加</button>
      </div>
    `,
      data() {
        return {
          count: 1
        }
      },
      methods: {
        handleClick() {
          if(this.count >= 3) return;
          const timer = setInterval(() => {
            this.count += 1
            if(this.count === 3) {
              clearInterval(timer)
            }
          }, 1000);
        }
      }
    })
    const vm = app.mount('#root');

  </script>
</body>

</html>